
package com.mengmeizi.db;

import android.content.ContentValues;
import android.database.Cursor;

public class ImageBufferDB {

    /** 表名 */
    public static String TABLE = "exit_buffer";

    public static String THUMBS = "thumbs";

    public static String IMAGE = "image";

    public static String PAGE = "page";

    public String thumbs;

    public String image;

    public String page;

    public static final String sql$createTable() {
        String sql = "create table if not exists " + TABLE //
                + " (_id INTEGER PRIMARY KEY AUTOINCREMENT,"//
                + THUMBS + " TEXT,"//
                + IMAGE + " TEXT,"//
                + PAGE + " TEXT"//
                + ")";
        return sql;
    }

    public static final String sql$dropTable() {
        return "drop table if exists " + TABLE;
    }

    public ContentValues conver3ContentValues() {
        ContentValues cv = new ContentValues();
        cv.put(THUMBS, thumbs);
        cv.put(IMAGE, image);
        cv.put(PAGE, page);
        return cv;
    }

    public static ImageBufferDB conver2Datas(Cursor cursor) {
        ImageBufferDB bufferDB = new ImageBufferDB();
        bufferDB.thumbs = cursor.getString(cursor.getColumnIndex(THUMBS));
        bufferDB.image = cursor.getString(cursor.getColumnIndex(IMAGE));
        bufferDB.page = cursor.getString(cursor.getColumnIndex(PAGE));
        return bufferDB;
    }

    public static String sql$selectAll() {
        return "select * from " + TABLE;
    }

    public String toString() {
        return "thumbs-->" + thumbs + "--image-->" + image + "--page-->" + page;
    }
}
